<template>
  <div>
    <!-- Breadcrumb Navigation area -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">Home</el-breadcrumb-item>
      <el-breadcrumb-item>Power</el-breadcrumb-item>
      <el-breadcrumb-item>Rights</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- Card view area -->
    <el-card>
      <!-- rights list -->
      <el-table :data="rightsList" style="width: 100%" border stripe>
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="authName" label="AuthName"></el-table-column>
        <el-table-column prop="path" label="Path"></el-table-column>
        <el-table-column prop="level" label="Permission Level">
          <template slot-scope="sp">
            <el-tag v-if="sp.row.level == 0">一级</el-tag>
            <el-tag v-else-if="sp.row.level == 1" type="success">二级</el-tag>
            <el-tag v-else-if="sp.row.level == 2" type="warning">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      rightsList: []
    }
  },
  methods: {
    async getRightsList() {
      const rs = await this.$http.get('rights/list')
      if (rs.meta.status !== 200) return this.$msg.error(rs.meta.msg)
      this.rightsList = rs.data
    }
  },
  /* when vue be created, auto callback this func */
  created() {
    /* get rights list data from server */
    this.getRightsList()
  }
}
</script>

<style lang="less" scoped>

</style>
